package com.model;

import java.util.HashMap;
import java.util.Map;

import org.nutz.json.Json;

/**
 * http请求的返回对象，有state和resContent属性，其中<br/>
 * <font color="red">state-{0:正常，1:请求异常,2:网络异常}，默认为0</font><br/>
 * <font color="red">resContent-返回的内容，默认为"{}"</font><br/>
 * 
 * @author samoin
 * 
 */
public class HttpResponseObject {

	private int state = 0;// 请求的返回状态
	private String resContent = "{}";// 请求的返回内容

	public HttpResponseObject() {
		super();
	}

	public HttpResponseObject(int state, String resContent) {
		super();
		this.state = state;
		this.resContent = resContent;
	}
	
	@SuppressWarnings("unchecked")
	public Map<String, Object> getHttpResponseObject(){
		if(getResContent().equals("") || getResContent().equals("{}")){
			return new HashMap<String, Object>();
		}
		return (Map<String, Object>) Json.fromJson(getResContent());
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public String getResContent() {
		return resContent;
	}

	public void setResContent(String resContent) {
		this.resContent = resContent;
	}

}
